package com.xiangxiangjd.analyse.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.xiangxiangjd.analyse.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xiangxiangjd.analyse.service.StructureMethodService;
import com.xiangxiangjd.analyse.bean.StructureMethod;
import com.xiangxiangjd.analyse.controller.model.ApiResultModel;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 肖守凯
 * @since 2021-03-08
 */
@Controller
@RequestMapping("/analyse/structureMethod")
public class StructureMethodController extends BaseController{




     /** 主页面 */
    @RequestMapping("admin/main.html")
    public String main(){
       return  "StructureMethod/StructureMethodMain";
    }
    /** 添加页面跳转
     * @return 返回页面
     */
    @RequestMapping(value = "admin/addStructureMethodHtml")
    public String addStructureMethodHtml( ){
             return "StructureMethod/StructureMethodAdd";
    }
    /** 编辑页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/editStructureMethodHtml")
    public String editStructureMethodHtml(String id ,Model model ){
           model.addAttribute("structureMethod",structureMethodService.selectStructureMethodByIdStructureMethod(id));
             return "StructureMethod/StructureMethodEdit";
    }

    /** 查看页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/showStructureMethodHtml")
    public String showStructureMethodHtml(String id ,Model model ){
           model.addAttribute("structureMethod",structureMethodService.selectStructureMethodByIdStructureMethod(id));
             return "StructureMethod/StructureMethodShow";
    }


    /** 分页查询StructureMethod
     * @param page  页码
     * @param limit  查几条
     * @param structureMethod  前端传进的参数
     * @return 返回统一分页信息
     */
    @RequestMapping(value = "admin/findStructureMethodByPage")
    @ResponseBody
    public ResultPage findStructureMethodByPage(Integer page, Integer limit,StructureMethod structureMethod){
             return structureMethodService.findStructureMethodByPage(page,limit,structureMethod);
    }

    /** 添加StructureMethod
     * @param structureMethod  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/addStructureMethod")
    @ResponseBody
    public ApiResultModel saveStructureMethod(StructureMethod structureMethod  ){
             return structureMethodService.addStructureMethod(structureMethod);
    }

    /** 编辑StructureMethod
     * @param structureMethod  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/editStructureMethod")
    @ResponseBody
    public ApiResultModel editStructureMethod(StructureMethod structureMethod  ){
             return structureMethodService.editStructureMethod(structureMethod);
    }



    /** 删除StructureMethod
     * @param ids  前端传进的ID
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/delStructureMethod",method = RequestMethod.GET)
    @ResponseBody
    public ApiResultModel delStructureMethod(@RequestParam("datas[]") ArrayList ids){


             return structureMethodService.delStructureMethods(ids);
    }


}
